<template>
	<view class="content">
		<myFilter v-show="mapHide == 0" ref="myMap" @search="search"></myFilter>
		<Search v-if="mapHide == 1" @patternLocalization="patternLocalization"></Search>
		<MyTabbar class="tabbar" :chengCurrent="chengCurrent" @sectionChange="sectionChange" ref="myTable"></MyTabbar>
	</view>
</template>

<script>
	import {
		GetLayersData,
		jumpPatternSpot
	} from "@/utils/initMap.js"
	import myFilter from "./component/myFilter.vue"
	import MyTabbar from "@/components/MyTabbar.vue"
	import Search from "./component/Search.vue"
	import {
		UrlParamHash
	} from "@/utils/auth.js"
	export default {
		data() {
			return {
				mapHide: 0,
				count: 0,
				chengCurrent: 0
			}
		},
		components: {
			myFilter,
			MyTabbar,
			Search
		},
		onShow() {
			this.extractToken()
			this.count++
			// if (this.count != 1) {
			// 	uni.showLoading({
			// 		title: '地块返回中'
			// 	});
			// 	this.$refs.myMap.int();

			// 	uni.hideLoading();
			// }

		},
		methods: {
			sectionChange(index) {
				this.mapHide = index;
			},
			search(params) {},
			// 提取token
			extractToken() {
				let {
					token
				} = UrlParamHash(window.location.href)
				var reg = new RegExp("#/");
				token = token.replace(reg, "");
				uni.setStorageSync("App-Token", token)
			},
			async patternLocalization(objectid) {
				const res = await GetLayersData([{
					name: 'objectid',
					value: objectid,
					type: 'objectid',
					isEq: true,
				}])
				console.log(res)
				this.chengCurrent++
				this.mapHide = 0
				this.$store.state.user.attributes = res[0]
				jumpPatternSpot(res[0].patternSpotGeo)
				this.$store.state.user.speckleData = res[0]
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tabbar {
		position: fixed;
		bottom: 50rpx;
		left: 50rpx;
		right: 50rpx;
	}
</style>